package controllers

import (
	"github.com/astaxie/beego"
	"xiegao/caches"
)

type TicketController struct {
	beego.Controller
}

// @Title 获取一个Ticket
// @Description 获取一个Ticket
// @Success 200 {"code":200,"msg":"获取成功","data":{"token":"Ticket"}}
// @router /ticket [get]
func (self *TicketController) Get() {
	TicketSession := caches.CreateTicketSession()
	ticket := TicketSession.GetTicket()
	if len(ticket) == 0 {
		self.Data["json"] = map[string]interface{}{"code": 500, "msg": "获取失败"}
		self.ServeJSON()
		self.StopRun()
	}
	self.Data["json"] = map[string]interface{}{"code": 200, "msg": "获取成功", "data": map[string]interface{}{"ticket": ticket}}
	self.ServeJSON()
	self.StopRun()
}
